home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / date / tcom / kermopt.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-04-08  |  2.9 KB  |  107 lines

  1. {$G+,X+}
  2.  
  3. {Conditional defines that may affect this unit}
  4. {$I AWDEFINE.INC}
  5.  
  6. {*********************************************************}
  7. {*                   KERMOPT.PAS 1.01                    *}
  8. {*        Copyright (c) TurboPower Software 1995         *}
  9. {*                 All rights reserved.                  *}
  10. {*********************************************************}
  11.  
  12. unit Kermopt;
  13.  
  14. interface
  15.  
  16. uses
  17.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  18.   Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, TComIni;
  19.  
  20. type
  21.   TKermitOptionsForm = class(TForm)
  22.     ErrorCorrectionBox: TRadioGroup;
  23.     GroupBox1: TGroupBox;
  24.     Label1: TLabel;
  25.     Label2: TLabel;
  26.     PaddingCountEdit: TEdit;
  27.     PaddingCharEdit: TEdit;
  28.     GroupBox2: TGroupBox;
  29.     Label3: TLabel;
  30.     HibitEdit: TEdit;
  31.     Label4: TLabel;
  32.     Label5: TLabel;
  33.     RepeatEdit: TEdit;
  34.     ControlEdit: TEdit;
  35.     GroupBox3: TGroupBox;
  36.     Label6: TLabel;
  37.     Label7: TLabel;
  38.     MaxLengthEdit: TEdit;
  39.     TerminatorEdit: TEdit;
  40.     OkBtn: TBitBtn;
  41.     CancelBtn: TBitBtn;
  42.     HelpBtn: TBitBtn;
  43.     procedure OkBtnClick(Sender: TObject);
  44.  
  45.   public
  46.     constructor Create(AOwner : TComponent); override;
  47.   end;
  48.  
  49. implementation
  50.  
  51. {$R *.DFM}
  52.  
  53. constructor TKermitOptionsForm.Create(AOwner : TComponent);
  54. begin
  55.   inherited Create(AOwner);
  56.  
  57.   ErrorCorrectionBox.ItemIndex := Ord(ErrCheck) - Ord('1');
  58.   PaddingCountEdit.Text        := IntToStr(PadCount);
  59.   PaddingCharEdit.Text         := IntToStr(Ord(PadChar));
  60.   HibitEdit.Text               := IntToStr(Ord(HiBitPrefix));
  61.   RepeatEdit.Text              := IntToStr(Ord(RepeatPrefix));
  62.   ControlEdit.Text             := IntToStr(Ord(CtlPrefix));
  63.   MaxLengthEdit.Text           := IntToStr(MaxPacketLen);
  64.   TerminatorEdit.Text          := IntToStr(Ord(Terminator));
  65. end;
  66.  
  67. procedure TKermitOptionsForm.OkBtnClick(Sender: TObject);
  68.  
  69.   function TestChar(Edit : TEdit) : Boolean;
  70.   var
  71.     E : Integer;
  72.     L : LongInt;
  73.  
  74.   begin
  75.     Val(Edit.Text, L, E);
  76.     if (E <> 0) or (L < 0) or (L > 255) then begin
  77.       MessageDlg('You must enter a numeric value between 0 and 255.', mtError, [mbOK], 0);
  78.       Edit.SetFocus;
  79.       Result := False
  80.     end else
  81.       Result := True;
  82.   end;
  83.  
  84. begin
  85.   if    not TestChar(PaddingCountEdit)
  86.      or not TestChar(PaddingCharEdit)
  87.      or not TestChar(HibitEdit)
  88.      or not TestChar(RepeatEdit)
  89.      or not TestChar(ControlEdit)
  90.      or not TestChar(MaxLengthEdit)
  91.      or not TestChar(TerminatorEdit) then
  92.     Exit;
  93.  
  94.   PadCount     := StrToInt(PaddingCountEdit.Text);
  95.   PadChar      := Char(StrToInt(PaddingCharEdit.Text));
  96.   HiBitPrefix  := Char(StrToInt(HibitEdit.Text));
  97.   RepeatPrefix := Char(StrToInt(RepeatEdit.Text));
  98.   CtlPrefix    := Char(StrToInt(ControlEdit.Text));
  99.   MaxPacketLen := StrToInt(MaxLengthEdit.Text);
  100.   Terminator   := Char(StrToInt(TerminatorEdit.Text));
  101.  
  102.   ErrCheck := Char(ErrorCorrectionBox.ItemIndex + Ord('1'));
  103. end;
  104.  
  105. end.
  106.  
  107.